package com.tarena.luban.worker.server.controller;

import com.tarena.luban.worker.server.domain.bo.TestWorkerBO;
import com.tarena.luban.worker.server.domain.service.TestWorkerService;
import com.tarena.luban.worker.server.protocol.query.TestWorkerQuery;
import com.tarena.luban.worker.server.vo.TestWorkerVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestWorkerController {
    @Autowired
    private TestWorkerService testWorkerService;
    @GetMapping("/test/worker")
    public TestWorkerVO testWorker(TestWorkerQuery testWorkerQuery){
        //调用业务层 传递testWorkerQuery 查询worker数据
        TestWorkerBO testWorkerBO=testWorkerService.testWorker(testWorkerQuery);
        //BO需要转化成VO 直接使用BeanUtils
        TestWorkerVO testWorkerVO=new TestWorkerVO();
        BeanUtils.copyProperties(testWorkerBO,testWorkerVO);
        return testWorkerVO;
    }
}
